﻿// ZKGKIN.cpp: 实现文件
//

#include "ZKGKIN.h"
#include "afxdialogex.h"
#include "../../DIO/DIO.h"
#include "../../DAO/DAO.h"
#include "../../UI/DIO/LOGIN.h"
#include "../../../QuantyView3DView.h"
//#include"../../../QuantyView3D.h"


using namespace DIO;
// ZKGKIN 对话框

IMPLEMENT_DYNAMIC(ZKGKIN, CDialogEx)

ZKGKIN::ZKGKIN(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_ZKGKIN, pParent)
{

}

ZKGKIN::~ZKGKIN()
{
}

void ZKGKIN::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_ZKGKLIST, ZKGKINLIST);
	DDX_Control(pDX, IDC_ZKGKIN_ADD, ZKGKIN_ADD);
}


BEGIN_MESSAGE_MAP(ZKGKIN, CDialogEx)
	ON_BN_CLICKED(IDC_ZKGKIN_ADD, &ZKGKIN::OnBnClickedZkgkinAdd)
END_MESSAGE_MAP()


// ZKGKIN 消息处理程序


BOOL ZKGKIN::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CString GKTitleName;
	GKTitleName = "钻孔概况表";

	DWORD dwStyle = ZKGKINLIST.GetExtendedStyle();
	ZKGKINLIST.SetExtendedStyle(dwStyle | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
	ZKGKINLIST.InsertColumn(0, _T("MDBTAD（勘探区编号）"), LVCFMT_CENTER, 200);
	ZKGKINLIST.InsertColumn(1, _T("GCJCBN(钻孔编号)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(2, _T("TKAA(钻孔类型)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(3, _T("TKCAF(X坐标)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(4, _T("TKCAG(Y坐标)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(5, _T("TKCAI(Z坐标)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(6, _T("TKALE(开孔日期)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(7, _T("TKALF(完孔日期)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(8, _T("GGHHAB(终孔深度)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(9, _T("PKGDCA(勘探线编号)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(10, _T("TKAIAB(钻孔方位角)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(11, _T("WTEUAA(钻孔倾角)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(12, _T("GGBGBD(编录人员)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(13, _T("GGDDIW(数据入库日期)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(14, _T("AUDITNAME(审核人)"), LVCFMT_CENTER, 140);
	ZKGKINLIST.InsertColumn(15, _T("AUDITTIME(审核日期)"), LVCFMT_CENTER, 140);
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void ZKGKIN::OnBnClickedZkgkinAdd()
{
	// TODO: 在此添加控件通知处理程序代码
	DrillGeneral_ST drill;

	CString zkgk_ktqbh;
	GetDlgItem(IDC_ZKGK_KTQBH)->GetWindowText(zkgk_ktqbh);
	if (zkgk_ktqbh.IsEmpty())
	{
		MessageBox("勘探区编号不能为空!", "提示", 0);
	}
	else {
		drill.kantanqu_no = zkgk_ktqbh;
	}
	
	CString zkgk_zkbh;
	GetDlgItem(IDC_ZKGK_ZKBH)->GetWindowText(zkgk_zkbh);
	if (zkgk_zkbh.IsEmpty())
	{
		MessageBox("钻孔编号不能为空!", "提示", 0);
	}
	else {
		drill.drill_no = zkgk_zkbh;
	}
	

	CString zkgk_zklx;
	GetDlgItem(IDC_ZKGK_ZKLX)->GetWindowText(zkgk_zklx);
	drill.type = zkgk_zklx;

	CString zkgk_zkx;
	GetDlgItem(IDC_ZKGK_ZKX)->GetWindowText(zkgk_zkx);
	double x = atof(zkgk_zkx);
	drill.x = x;

	CString zkgk_zky;
	GetDlgItem(IDC_ZKGK_ZKY)->GetWindowText(zkgk_zky);
	double y = atof(zkgk_zky);
	drill.y = y;

	CString zkgk_zkz;
	GetDlgItem(IDC_ZKGK_ZKZ)->GetWindowText(zkgk_zkz);
	double z = atof(zkgk_zkz);
	drill.z = z;

	CString zkgk_kgrq;
	GetDlgItem(IDC_ZKGK_KKRQ)->GetWindowText(zkgk_kgrq);
	drill.type = zkgk_zklx;

	CString zkgk_wkrq;
	GetDlgItem(IDC_ZKGK_WKRQ)->GetWindowText(zkgk_wkrq);
	drill.zhongkong = zkgk_wkrq;

	CString zkgk_zksd;
	GetDlgItem(IDC_ZKGK_ZKSD)->GetWindowText(zkgk_zksd);
	double deepth = atof(zkgk_zksd);
	drill.deepth = deepth;

	CString zkgk_ktxbh;
	GetDlgItem(IDC_ZKGK_KTXBH)->GetWindowText(zkgk_ktxbh);//勘探线编号
	drill.PKGDCA = zkgk_ktxbh;

	CString zkgk_zkfwj;
	GetDlgItem(IDC_ZKGK_ZKFWJ)->GetWindowText(zkgk_zkfwj);
	double TKATAB = atof(zkgk_zkfwj);
	drill.TKATAB = TKATAB;

	CString zkgk_zkqj;
	GetDlgItem(IDC_ZKGK_ZKQJ)->GetWindowText(zkgk_zkqj);
	double WTEUAA = atof(zkgk_zkqj);
	drill.WTEUAA = WTEUAA;

	CString zkgk_blry;
	GetDlgItem(IDC_ZKGK_BLRY)->GetWindowText(zkgk_blry);
	drill.GGBGBD = zkgk_blry;

	CString zkgk_sjrkrq;
	GetDlgItem(IDC_ZKGK_SJRKRQ)->GetWindowText(zkgk_sjrkrq);
	drill.GGDDIW = zkgk_sjrkrq;

	CString zkgk_shr;
	GetDlgItem(IDC_ZKGK_SHR)->GetWindowText(zkgk_shr);
	drill.AUDITTNAME = zkgk_shr;

	CString zkgk_shrq;
	GetDlgItem(IDC_ZKGK_SHRQ)->GetWindowText(zkgk_shrq);
	drill.AUDITTIME = zkgk_shrq;

		int nindex = ZKGKINLIST.InsertItem(1, zkgk_ktqbh);
		ZKGKINLIST.SetItemText(nindex, 1, zkgk_zkbh);
		ZKGKINLIST.SetItemText(nindex, 2, zkgk_zklx);
		ZKGKINLIST.SetItemText(nindex, 3, zkgk_zkx);
		ZKGKINLIST.SetItemText(nindex, 4, zkgk_zky);
		ZKGKINLIST.SetItemText(nindex, 5, zkgk_zkz);
		ZKGKINLIST.SetItemText(nindex, 6, zkgk_kgrq);
		ZKGKINLIST.SetItemText(nindex, 7, zkgk_wkrq);
		ZKGKINLIST.SetItemText(nindex, 8, zkgk_zksd);
		ZKGKINLIST.SetItemText(nindex, 9, zkgk_ktxbh);
		ZKGKINLIST.SetItemText(nindex, 10, zkgk_zkfwj);
		ZKGKINLIST.SetItemText(nindex, 11, zkgk_zkqj);
		ZKGKINLIST.SetItemText(nindex, 12, zkgk_blry);
		ZKGKINLIST.SetItemText(nindex, 13, zkgk_sjrkrq);
		ZKGKINLIST.SetItemText(nindex, 14, zkgk_shr);
		ZKGKINLIST.SetItemText(nindex, 15, zkgk_shrq);

		User_ST uu;
		uu.name = user.name;
		uu.password = user.password;
		//view->setUser(user);
		UserInsertDMZK0401(drill);
		
		DIO::UserBind(uu, drill);
		
		

}
